package data;

import java.util.Date;

import com.EntityName;
import com.google.appengine.api.datastore.Entity;

public class travel extends AbstractData{

	private long id = -1;
	private long hotelId;
	private String tarvelby;
	private String arraive;
	private Date time;
	private boolean addTask;
	private String tarvelbyBack;
	private String arraiveBack;
	private Date timeBack;
	private boolean addTaskBack;
	private boolean showTime;
	private boolean showTimeBack;
	private boolean status;
	private boolean avaliable;
	
	public travel(){
		
	}
	
	public travel(long id)
	{
		this.id = id;
	}
		
	public void setId(long id) {
		this.id = id;
	}

	
	public long getId() {
		return id;
	}

	public long getHotelId() {
		return hotelId;
	}

	public void setHotelId(long hotelId) {
		this.hotelId = hotelId;
	}

	public String getTarvelby() {
		return tarvelby;
	}

	public void setTarvelby(String tarvelby) {
		this.tarvelby = tarvelby;
	}

	public String getArrive() {
		return arraive;
	}

	public void setArrive(String arrive) {
		this.arraive = arrive;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public boolean isAddTask() {
		return addTask;
	}

	public void setAddTask(boolean addTask) {
		this.addTask = addTask;
	}
	

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	public boolean isAvaliable() {
		return avaliable;
	}

	public void setAvaliable(boolean avaliable) {
		this.avaliable = avaliable;
	}

	
	public String getTarvelbyBack() {
		return tarvelbyBack;
	}

	public void setTarvelbyBack(String tarvelbyBack) {
		this.tarvelbyBack = tarvelbyBack;
	}

	public String getArriveBack() {
		return arraiveBack;
	}

	public void setArriveBack(String arriveBack) {
		this.arraiveBack = arriveBack;
	}

	public Date getTimeBack() {
		return timeBack;
	}

	public void setTimeBack(Date timeBack) {
		this.timeBack = timeBack;
	}

	public boolean isAddTaskBack() {
		return addTaskBack;
	}

	public void setAddTaskBack(boolean addTaskBack) {
		this.addTaskBack = addTaskBack;
	}
	
	public boolean isShowTime() {
		return showTime;
	}

	public void setShowTime(boolean showTime) {
		this.showTime = showTime;
	}
	
	public boolean isShowTimeBack() {
		return showTimeBack;
	}

	public void setShowTimeBack(boolean showTimeBack) {
		this.showTimeBack = showTimeBack;
	}

	@Override
	public Entity getEntity()
	{
		Entity item;
		if(this.key == null)
			item = new Entity(EntityName.Travel);
		else
			item = new Entity(this.key);
		
		item.setProperty("hotelId", this.hotelId);
		item.setProperty("tarvelby", this.tarvelby);
		item.setProperty("arraive", this.arraive);
		item.setProperty("time",this.time);
		item.setProperty("addTask",this.addTask);
		item.setProperty("tarvelbyBack", this.tarvelbyBack);
		item.setProperty("arraiveBack", this.arraiveBack);
		item.setProperty("timeBack",this.timeBack);
		item.setProperty("addTaskBack",this.addTaskBack);
		item.setProperty("status",this.status);
		item.setProperty("avaliable",this.avaliable);
		item.setProperty("showTime",this.showTime);
		item.setProperty("showTimeBack",this.showTimeBack);
		
		
		return item;
	}

	@Override
	public void setEntity(Entity entity) {
		
		this.id = entity.getKey().getId();
		this.hotelId = (Long) entity.getProperty("hotelId");
		this.tarvelby= (String) entity.getProperty("tarvelby");
		this.arraive= (String) entity.getProperty("arraive");
		this.time =(Date) entity.getProperty("time");
		if(entity.getProperty("addTask")==null||entity.getProperty("addTask") ==""){
			this.addTask =false;
		}else{
			this.addTask =(Boolean)entity.getProperty("addTask");
		}
		this.tarvelbyBack= (String) entity.getProperty("tarvelbyBack");
		this.arraiveBack= (String) entity.getProperty("arraiveBack");
		this.timeBack =(Date) entity.getProperty("timeBack");
		if(entity.getProperty("addTaskBack")==null||entity.getProperty("addTaskBack") ==""){
			this.addTaskBack =false;
		}else{
			this.addTaskBack =(Boolean)entity.getProperty("addTaskBack");
		}
		this.status= (Boolean) entity.getProperty("status");
		this.avaliable =(Boolean) entity.getProperty("avaliable");
		this.showTime =(Boolean) entity.getProperty("showTime");
		this.showTimeBack =(Boolean) entity.getProperty("showTimeBack");
	
		this.key = entity.getKey();
	}
	
	public void LoadData() {
		if (this.id > -1) {
			Entity entity = LoadData(EntityName.Travel, this.id);
			setEntity(entity);
		}
	}

}
